import { createRouter, createWebHashHistory  } from 'vue-router'

import PageHome from '../pages/home/page-home.vue'

const router = createRouter({
  history: createWebHashHistory(),
  routes: [
    {
      path: '/',
      meta: { title: '蜗牛商城后台管理系统' },  // 路由的元信息
      redirect: '/main',
      component:  PageHome,
      children: [
        {
          path: 'main',
          meta: {title: '蜗牛商城-首页'},
          component: ()=>import('./../pages/home/page-main.vue')
        },
        {
          path: 'goodsAdd',
          meta: {title: '商品添加'},
          component: ()=>import('./../pages/goods/page-goodsAdd.vue')
        },
        {
          path: 'goodsList',
          meta: {title: '商品列表'},
          component: ()=>import('./../pages/goods/page-goodsList.vue')
        },
      ]
    },
    {
      path: '/login',
      meta: { title: '蜗牛商场-登录'},
      component:  ()=>import('./../pages/login/page-login.vue')
    },
    {
      path: '/maopao',
      component:  ()=>import('./../pages/zhishi/page-01.vue')
    },
    {
      path: '/biaodan',
      component:  ()=>import('./../pages/zhishi/page-02.vue')
    },
    {
      path: '/chuancan1',
      component:  ()=>import('./../pages/zhishi/page-11.vue')
    },
    {
      path: '/chuancan2',
      component:  ()=>import('./../pages/zhishi/page-12.vue')
    },
    {
      path: '/chuancan3',
      component:  ()=>import('./../pages/zhishi/page-13.vue')
    },
    {
      path: '/huancun',
      component:  ()=>import('./../pages/zhishi/page-10.vue'),
      children: [
        {
          path: 'form',
          component: ()=>import('@/components/zhishi/ten-form.vue')
        },
        {
          path: 'form1',
          component: ()=>import('@/components/zhishi/ten-form1.vue')
        }
      ]
    },
    {
      path: '/zhengze',
      component:  ()=>import('./../pages/zhishi/page-03.vue')
    },
    {
      path: '/wendang',
      component:  ()=>import('./../pages/zhishi/page-05.vue')
    },
    {
      path: '/zujian',
      component:  ()=>import('./../pages/zhishi/page-06.vue')
    },
    {
      path: '/bianjiqi',
      component:  ()=>import('./../pages/zhishi/page-07.vue')
    },
    {
      path: '/biaodanxiang',
      component:  ()=>import('./../pages/zhishi/page-08.vue')
    },
    {
      path: '/key',
      component:  ()=>import('./../pages/zhishi/page-09.vue')
    },
    {
      path: '/:pathMatch(.*)',
      redirect: '/main'
    }
  ] // 路由规则
})
// 导航前置守卫
router.beforeEach((to)=>{
  document.title = to.meta.title
})

export default router
